// Proxy 是 ES6 中新增的功能，它可以用来自定义对象中的操作
const reactiveData = {
  count: 0
}

const reactiveProxy = new Proxy(reactiveData, {
  get (target, key, receiver) {
    console.log('访问属性:', key)
    return Reflect.get(target, key, receiver)
  },
  set (target, key, value, receiver) {
    console.log('设置属性:', key, '值:', value)
    const result = Reflect.set(target, key, value, receiver)
    // 触发更新操作，比如通知视图更新
    updateView()
    return result
  }
})

// 视图更新函数
function updateView () {
  console.log('视图更新:', reactiveProxy.count)
}
// 测试
console.log(reactiveProxy.count) // 访问属性: count，1
reactiveProxy.count = 1; // 设置属性: count 值: 1，视图更新: 1

// const url = "https://www.example.com/search?keyword=编程&category=技术";
// const encodedURL = encodeURIComponent(url);
// console.log(encodedURL); 